import { IPSDEServiceAPI } from '../dataentity/service/ipsdeservice-api';
import { IPSDEServiceAPIRS } from '../dataentity/service/ipsdeservice-apirs';
import { IPSSysSFPlugin } from '../res/ipssys-sfplugin';
import { IPSSysServiceAPI } from './ipssys-service-api';
import { IPSSystemModule } from '../system/ipssystem-module';
import { IPSSysTestPrj } from '../testing/ipssys-test-prj';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysServiceAPIImpl extends PSModelObjectImpl implements IPSSysServiceAPI {
  get aPILevel(): 0 | 1 | 2 | 3 {
    return this.M.aPILevel != null ? this.M.aPILevel : 3;
  }

  get aPIMode(): 0 | 1 | 2 | 10 {
    return this.M.aPIMode;
  }

  get aPITag(): string {
    return this.M.aPITag;
  }

  get aPITag2(): string {
    return this.M.aPITag2;
  }

  get aPIType(): 'RESTFUL' | 'JAXRS' | 'WEBSERVICE' | 'USER' | 'USER2' {
    return this.M.aPIType;
  }

  get aPIVersion(): number {
    return this.M.aPIVersion;
  }

  get authCheckTokenUrl(): string {
    return this.M.authCheckTokenUrl;
  }

  get authClientId(): string {
    return this.M.authClientId;
  }

  get authClientSecret(): string {
    return this.M.authClientSecret;
  }

  get authMode(): 'NONE' | 'AUTHORIZATION_CODE' | 'PASSWORD' | 'CLIENT_CREDENTIALS' | 'IMPLICIT' | 'USER' | 'USER2' {
    return this.M.authMode;
  }

  get authParam(): string {
    return this.M.authParam;
  }

  get authParam2(): string {
    return this.M.authParam2;
  }

  get authParam3(): string {
    return this.M.authParam3;
  }

  get authParam4(): string {
    return this.M.authParam4;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get handler(): string {
    return this.M.handler;
  }

  get httpPort(): number {
    return this.M.httpPort;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeserviceapirss: IPSDEServiceAPIRS[] | null = null;

  getPSDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    if (this.psdeserviceapirss == null) {
      this.psdeserviceapirss = this.fillChildListModel(this.M.getPSDEServiceAPIRSs, 'dataentity.service.IPSDEServiceAPIRS') as IPSDEServiceAPIRS[];
    }
    return this.psdeserviceapirss;
  }

  get psDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    return this.getPSDEServiceAPIRSs();
  }

  findPSDEServiceAPIRS(objKey: any): IPSDEServiceAPIRS | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIRS', this.getPSDEServiceAPIRSs(), objKey) as IPSDEServiceAPIRS;
  }

  protected psdeserviceapis: IPSDEServiceAPI[] | null = null;

  getPSDEServiceAPIs(): IPSDEServiceAPI[] | null {
    if (this.psdeserviceapis == null) {
      this.psdeserviceapis = this.fillChildListModel(this.M.getPSDEServiceAPIs, 'dataentity.service.IPSDEServiceAPI') as IPSDEServiceAPI[];
    }
    return this.psdeserviceapis;
  }

  get psDEServiceAPIs(): IPSDEServiceAPI[] | null {
    return this.getPSDEServiceAPIs();
  }

  findPSDEServiceAPI(objKey: any): IPSDEServiceAPI | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPI', this.getPSDEServiceAPIs(), objKey) as IPSDEServiceAPI;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端扩展插件');
    }
    return value;
  }

  protected pssystestprjs: IPSSysTestPrj[] | null = null;

  getPSSysTestPrjs(): IPSSysTestPrj[] | null {
    if (this.pssystestprjs == null) {
      this.pssystestprjs = this.fillChildListModel(this.M.getPSSysTestPrjs, 'testing.IPSSysTestPrj') as IPSSysTestPrj[];
    }
    return this.pssystestprjs;
  }

  get psSysTestPrjs(): IPSSysTestPrj[] | null {
    return this.getPSSysTestPrjs();
  }

  findPSSysTestPrj(objKey: any): IPSSysTestPrj | null {
    return this.getPSModel5('testing.IPSSysTestPrj', this.getPSSysTestPrjs(), objKey) as IPSSysTestPrj;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  get predefinedType(): 'SAASADMIN' | 'WFSERVICE' | 'WFPROXYAPP' | 'WFCALLBACK' | 'USERAUTH' | 'ORGSERVICE' | 'ORGCALLBACK' | 'CORESERVICE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.predefinedType;
  }

  get serviceCodeName(): string {
    return this.M.serviceCodeName;
  }

  get serviceParam(): string {
    return this.M.serviceParam;
  }

  get serviceParam2(): string {
    return this.M.serviceParam2;
  }

  get serviceParam3(): string {
    return this.M.serviceParam3;
  }

  get serviceParam4(): string {
    return this.M.serviceParam4;
  }

  get serviceType(): 'DEFAULT' | 'IBIZCLOUD' | 'APPLICATION' | 'LOCAL' | 'MIDDLEPLATFORM' | 'USER' | 'USER2' {
    return this.M.serviceType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cloudAdminLevel(): boolean {
    return this.M.cloudAdminLevel != null ? this.M.cloudAdminLevel : false;
  }

  get coreLevel(): boolean {
    return this.M.coreLevel != null ? this.M.coreLevel : false;
  }

  get dCAdminLevel(): boolean {
    return this.M.dCAdminLevel != null ? this.M.dCAdminLevel : false;
  }

  get enableServiceAPIDTO(): boolean {
    return this.M.enableServiceAPIDTO != null ? this.M.enableServiceAPIDTO : false;
  }

  get userLevel(): boolean {
    return this.M.userLevel != null ? this.M.userLevel : false;
  }

  get cls(): string {
    return 'PSSysServiceAPIImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'service.IPSSysServiceAPI') return true;
    return super.instanceof(cls);
  }
}
